#!/bin/sh
repos="D:/PROJECT_FOLDER/"
repos_regex="D:\/PROJECT_FOLDER\/"      # in regex format, / -> \/, . -> \.
tomcat="D:/tomcat/"
cd $repos

# version number for patch files (in regex format)
version_tag="8.07.00_v16_b3"
patch='patch_'${version_tag}

# create ${patch} folders
rm -rf ${repos}${patch}
mkdir -p ${repos}${patch}/database/Procs
mkdir -p ${repos}${patch}/database/Script
mkdir -p ${repos}${patch}/database/Seq
mkdir -p ${repos}${patch}/database/Table/alter
mkdir -p ${repos}${patch}/database/Table/create
mkdir -p ${repos}${patch}/database/Table/index
mkdir -p ${repos}${patch}/database/Table/insert
mkdir -p ${repos}${patch}/database/Table/mod
mkdir -p ${repos}${patch}/database/Table/update
mkdir -p ${repos}${patch}/database/Trig
mkdir -p ${repos}${patch}/database/View
mkdir -p ${repos}${patch}/tomcat/common/lib
mkdir -p ${repos}${patch}/tomcat/WEB-INF/classes/com/laconic
cat ${repos}source/database/setup.bat | sed 's/VERSION_TAG/'${version_tag}'/g' > ${repos}${patch}/database/patch.bat
cat ${repos}utilities/release_seed/patch_tomcat.bat | sed 's/VERSION_TAG/'${version_tag}'/g' > ${repos}${patch}/tomcat/patch.bat

# web files
cp -r ${repos}source/laconic/web/css ${repos}${patch}/tomcat
cp -r ${repos}source/laconic/web/downloads ${repos}${patch}/tomcat
cp -r ${repos}source/laconic/web/flow ${repos}${patch}/tomcat
cp -r ${repos}source/laconic/web/html5 ${repos}${patch}/tomcat
cp -r ${repos}source/laconic/web/img ${repos}${patch}/tomcat
cp -r ${repos}source/laconic/web/inc ${repos}${patch}/tomcat
cp -r ${repos}source/laconic/web/includes ${repos}${patch}/tomcat
cp -r ${repos}source/laconic/web/jasper ${repos}${patch}/tomcat
cp -r ${repos}source/laconic/web/js ${repos}${patch}/tomcat
cp -r ${repos}source/laconic/web/jsp ${repos}${patch}/tomcat
cp -r ${repos}source/laconic/web/META-INF ${repos}${patch}/tomcat
cp -r ${repos}source/laconic/web/open-iconic ${repos}${patch}/tomcat
cp -r ${repos}source/laconic/web/remoteScript ${repos}${patch}/tomcat
cp -r ${repos}source/laconic/web/text ${repos}${patch}/tomcat
# meta stuffs
cp ${repos}source/laconic/web/index.jsp ${repos}${patch}/tomcat
cp -r ${repos}source/laconic/web/WEB-INF/tld ${repos}${patch}/tomcat/WEB-INF
cp ${repos}source/laconic/web/WEB-INF/web.xml ${repos}${patch}/tomcat/WEB-INF
# class files
cp -r ${tomcat}webapps/laconic/WEB-INF/classes/com/laconic ${repos}${patch}/tomcat/WEB-INF/classes/com
# class file for common
cp ${tomcat}common/lib/common.jar ${repos}${patch}/tomcat/common/lib
# database files
cp -r ${repos}source/database ${repos}${patch}
